
#include "Dlist_t.h"




template <class T> void Dlist_t<T>::insert(const T* elem) {

	append(elem, numOfElements - 1); //append after last index.
}
	
template <class T> void Dlist_t<T>::append(const T* elem, int index) {

	
}
	
template <class T> void Dlist_t<T>::prepend(const T* elem, int index) { 

	
}

template <class T> T* Dlist_t<T>::remove(const T& value) {

	node<T>* curr = head;

	node<T>* tmpNext = 0;

	while (curr != 0) {   //deletes all nodes.

		tmpNext = curr->getNext();
		delete curr;
		curr = tmpNext;
	}

	Container_t<T>::remove();  //decreases numOfElements by 1.	

	return 0;  //not found - null ptr.
}

template <class T> void Dlist_t<T>::removeAndDelete(const T& value) {

	delete remove(value);  //if remove(value) == 0, delete does nothing.
}


template <class T> virtual void Dlist_t<T>::removeAll() {

	node<T>* curr = head;

	node<T>* tmpNext = 0;

	while (curr != 0) {   //deletes all nodes.

		tmpNext = curr->getNext();
		delete curr;
		curr = tmpNext;
	}

	Container_t<T>::removeAll();   //sets numOfElements to 0.
}


template <class T> virtual void Dlist_t<T>::removeAndDeleteAll() {

	node<T>* curr = head;

	node<T>* tmpNext = 0;

	while (curr != 0) {   //deletes all nodes and all elements (their data).

		tmpNext = curr->getNext();
		delete curr->getData();
		delete curr;
		curr = tmpNext;
	}

	Container_t<T>::removeAndDeleteAll();  //sets numOfElements to 0.
}

template <class T> T* Dlist_t<T>::Next() {
	
	if (currNode == tail) {
		return 0;
	}

	return currNode->getPrev()->getData();
}

template <class T> T* Dlist_t<T>::Prev() {
	
	if (currNode == head) {
		return 0;
	}

	currNode->getPrev()->getData();
}


template <class T> void Dlist_t<T>::Reset() {
	
	currNode = head;
}